package cn.szzsi._web;

import cn.szzsi.common.model.Deposit;
import cn.szzsi.common.model.PaymentConfig;
import cn.szzsi.common.model.Withdraw;

import java.util.List;

/**
 * 前台类 - 预存款
 * 
 */
public class DepositController extends BaseWebController<Deposit> {

	private String path;//模板路径
	private String shopId;//用户的shopId就是商户的id

	/**
	 *预存款列表
 	 */
	public void list() {
		shopId=getLoginMember().getStr("shopId");//用户的shopId对应商户的id(uid),商户的shopId为"-1"
		findBusinessByPage(shopId,"mall_deposit");
		getTemplatePath(shopId,"deposit_list");
	}

	/**
	 * 提现
	 */
	public void withdraw(){
		if(getRequest().getMethod().equals("GET")){
            getTemplatePath(shopId,"deposit_input");
        }else{
            Withdraw wd = getModel(Withdraw.class);
            wd.save();
        }
	}

	/**
	 *预存款充值
 	 */
	public void recharge() {
		setAttr("nonDepositOfflinePaymentConfigList", getNonDepositOfflinePaymentConfigList(shopId));
		getTemplatePath(shopId,"deposit_recharge");
	}

	/**
	 * 获取支付配置（不包含预存款、线下支付方式）
	 */
	public List<PaymentConfig> getNonDepositOfflinePaymentConfigList(String shopId) {
		return PaymentConfig.dao.getNonDepositOfflinePaymentConfigList(shopId);
	}
}
